int fun(int a, int b) {
    if (a == b || a == 0)
        return 1;
    else
        return 0;
}
class Solution {
public:
    vector<vector<int>> imageSmoother(vector<vector<int>>& img) {
        int n = img.size(), m = img[0].size();
        vector<vector<int>> ret(n,vector<int>(m));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                int tmp = 1;
                ret[i][j] += img[i][j];
                if (i != 0 && j != 0)
                    ret[i][j] += img[i - 1][j - 1], tmp++;
                if (i != n - 1 && j != 0)
                    ret[i][j] += img[i + 1][j - 1], tmp++;
                if (i != 0 && j != m - 1)
                    ret[i][j] += img[i - 1][j + 1], tmp++;
                if (i != n - 1 && j != m - 1)
                    ret[i][j] += img[i + 1][j + 1], tmp++;
                if (i != 0)
                    ret[i][j] += img[i - 1][j], tmp++;
                if (i != n - 1)
                    ret[i][j] += img[i + 1][j], tmp++;
                if (j != 0)
                    ret[i][j] += img[i][j - 1], tmp++;
                if (j != m - 1)
                    ret[i][j] += img[i][j + 1], tmp++;
                // cout << ret[i][j] <<' ' << tmp << ':';
                ret[i][j] /= tmp;
            }
            cout <<endl;
        }
        return ret;
    }
};